<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="logList">
      <el-table-column label="订单来源" align="center" prop="syncSource" >
        <template slot-scope="scope">
          <span>{{scope.row.syncSource|syncSource }}</span>
        </template>
      </el-table-column>
      <el-table-column label="同步开始时间" align="center" prop="syncStartTime" width="180"/>
      <el-table-column label="同步结束时间" align="center" prop="syncEndTime" width="180"/>
      <el-table-column label="同步订单数" align="center" prop="numberOfSync" />
      <el-table-column label="备注" align="center" prop="remark" />
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
import { listLog } from "@/api/ota/ctrip";

export default {
  name: "Log",
  data() {
    return {
      // 遮罩层
      loading: true,
      total: 0,
      logList: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
    };
  },
  filters: {
    syncSource(val) {
      return {
        1: '携程',
        2: '悟空',
        3: '飞猪',
      } [Number(val)] || '--';
    },
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      listLog(this.queryParams).then(response => {
        this.logList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    }
  }
};
</script>
